package simulator.eventHandler;

import simulator.Event;
import simulator.EventHandler;
import simulator.Result;
import simulator.Unit;
import simulator.unit.*;

public class StatisticEventHandler implements EventHandler{

	private long dataCenterFailures = 0;
	private long rackFailures = 0;
	private long machineFailures = 0;
	public Result end() {
		System.out.println("dataCenterFailures="+dataCenterFailures);
		System.out.println("rackFailures="+rackFailures);
		System.out.println("machineFailures="+machineFailures);
		return null;
	}

	public void handleEvent(Event e) {
		if(e.getType()==Event.EventType.Failure){
			if(e.getUnit() instanceof DataCenter){
				dataCenterFailures++;
			}
			else if(e.getUnit() instanceof Rack){
				rackFailures++;
			}
			else if(e.getUnit() instanceof Machine){
				machineFailures++;
			}
		}
		
	}

	public void start(Unit root) {
		
	}

}
